﻿using UnityEngine;
using System.Collections;

public class Timer : MonoBehaviour {
	public float myTimer;
	private GUIStyle style;
	public bool gameOver = false;

	// Use this for initialization
	void Start () {
		style = new GUIStyle ();
		style.fontSize += 25;
		myTimer = 30f;
	}
	
	// Update is called once per frame
	void Update () {
		if(myTimer > 0)
		{
			myTimer -= Time.deltaTime;
		}
		if(myTimer <= 0)
		{
			gameOver = true;
		}
	}

	// show the timer
	void OnGUI () {
		int minutes = (int)(myTimer / 60);
		int seconds = (int)(myTimer % 60);
		int fraction= (int)((myTimer * 100) % 100);
		string guiTime = string.Format ("{0:00}:{1:00}:{2:000}", minutes, seconds, fraction); 
		GUI.Label(new Rect(250,80,150,50), guiTime, style);
	}
}
